/*
 *                    COPYRIGHT NOTICE
 *
 *           This code is copyright protected by Freedom Inc.
 *
 *              2001-2012 All Rights Are Reserved
 */
package com.freedom.oldsong.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.apache.log4j.Logger;

import com.freedom.oldsong.util.LanguageUtil;

/**
 * @author steven.wang
 *
 */
public final class AppConstants {
	
	private static final Logger logger=Logger.getLogger(AppConstants.class);
	
	public final static String SYS_ERROR_MSG = "Service unavailable, please contact system administrator";
	
	public static final String USER_INFO = "USER_INFO";
	
	public static final String ACTION = "action";
	
	public static final String SYS_CONFIG = "SYS_CONFIG";
	
	public static final String SERVER_ADRESS = "server_adress";
	
	private static Map<String ,Properties> configMap = new HashMap<String ,Properties>();
	
	private AppConstants(){
		
	}
	
	static{
			InputStream in = LanguageUtil.class.getResourceAsStream("/config.properties");
			Properties p = new Properties();
			try {
				p.load(in);
			} catch (IOException e) {
				logger.error(e.getMessage());
			}
			configMap.put(SYS_CONFIG, p);
	}
	
	public static String getConfigValue(String key){
		Properties p = configMap.get(SYS_CONFIG);
		if(p!=null){
			return (String)p.get(key);
		}
		return "";
	}
}
